*Replikationssyntax f�r Mader & Fiebig (2014): Determinanten der Bev�lkerungseinstellungen zum Afghanistan-Einsatz: 
*Pr�dispositionen, Erfolgswahrnehmungen und die moderierende Wirkung individueller Mediennutzung. In: Biehl/Schoen (Hrsg.)

*�ffnen des Datensatzes: SOWI Bev�lkerungsumfrage 2011, 2. Welle (November)
clear
use "...\Bev�lkerungsumfrage_Welle2.DTA"
set more off



*AV: Zustimmung ISAF in Afgh
recode V3011_1 (1 = 4)(2 = 3)(3 = 2)(4 = 1), gen(isaf)
mvdecode isaf, mv(98 = .a \ 99 = .b)

recode V3014 (1 = 1)(2 = 0), gen(abzug)
mvdecode abzug, mv(98 = .a \ 99 = .b)

foreach var of varlist isaf {
gen `var'_r = (`var' - 1)/3
}
foreach x of varlist isaf_r {
   egen `x'z = std(`x')
}




*UV/AV: Erfolg von ISAF
recode V3013 (1 = 5)(2 = 4)(3 = 3)(4 = 2) (5 = 1), gen(succ)
mvdecode succ, mv(98 = .a \ 99 = .b)

foreach var of varlist succ {
gen `var'_r = (`var' - 1)/4
}
foreach var of varlist succ_r {
   egen `var'z = std(`var')
}

*UV/AV: au�en- und sicherheitspolitische Pr�dispositionen
recode V3004_1 (1 = 4)(2 = 3)(3 = 2)(4 = 1), gen(pre1)
mvdecode pre1, mv(98 = .a \ 99 = .b)

gen pre2 = V3004_2
mvdecode pre2, mv(98 = .a \ 99 = .b)

recode V3004_3 (1 = 4)(2 = 3)(3 = 2)(4 = 1), gen(pre3)
mvdecode pre3, mv(98 = .a \ 99 = .b)

gen pre4 = V3004_4
mvdecode pre4, mv(98 = .a \ 99 = .b)

recode V3004_5 (1 = 4)(2 = 3)(3 = 2)(4 = 1), gen(pre5)
mvdecode pre5, mv(98 = .a \ 99 = .b)

recode V3004_6 (1 = 4)(2 = 3)(3 = 2)(4 = 1), gen(pre6)
mvdecode pre6, mv(98 = .a \ 99 = .b)

recode V3004_7 (1 = 4)(2 = 3)(3 = 2)(4 = 1), gen(pre7)
mvdecode pre7, mv(98 = .a \ 99 = .b)

egen inter = rowmean(pre1 pre2)


foreach var of varlist pre1-pre7 inter {
gen `var'_r = (`var' - 1)/3
}
foreach x of varlist pre1_r-pre7_r inter_r {
   egen `x'z = std(`x')
}



**parteipolitische Pr�dispositionen
recode V121 (11 12 14 = 1) (13 15 16 17 18 19 20 = 0), gen(idgov)
mvdecode idgov, mv(98 = .a \ 99 = .b)

foreach x of varlist idgov {
   egen `x'_rz = std(`x')
}

*UV: Einstellung BW
recode V3001_9 (1 = 4)(2 = 3)(3 = 2)(4 = 1), gen(bw1)
mvdecode bw1, mv(98 = .a \ 99 = .b)

gen bw2 = V3008_6
mvdecode bw2, mv(98 = .a \ 99 = .b)

recode V3007 (1 = 4)(2 = 3)(3 = 2)(4 = 1), gen(bw3)
mvdecode bw3, mv(98 = .a \ 99 = .b)

egen bw = rowmean(bw1 bw2 bw3)

foreach var of varlist bw {
gen `var'_r = (`var' - 1)/3
}
foreach var of varlist bw_r {
   egen `var'z = std(`var')
}



*UV: Mediennutzung

recode V3018_3 (1 = 5)(2 = 4)(3 = 3)(4 = 2) (5 = 1), gen(med3)
mvdecode med3, mv(98 = .a \ 99 = .b)

recode V3018_7 (1 = 5)(2 = 4)(3 = 3)(4 = 2) (5 = 1), gen(med7)
mvdecode med7, mv(98 = .a \ 99 = .b)

recode V3018_11 (1 = 5)(2 = 4)(3 = 3)(4 = 2) (5 = 1), gen(med11)
mvdecode med11, mv(98 = .a \ 99 = .b)
recode V3018_12 (1 = 5)(2 = 4)(3 = 3)(4 = 2) (5 = 1), gen(med12)
mvdecode med12, mv(98 = .a \ 99 = .b)
recode V3018_13 (1 = 5)(2 = 4)(3 = 3)(4 = 2) (5 = 1), gen(med13)
mvdecode med13, mv(98 = .a \ 99 = .b)
recode V3018_14 (1 = 5)(2 = 4)(3 = 3)(4 = 2) (5 = 1), gen(med14)
mvdecode med14, mv(98 = .a \ 99 = .b)

egen medweb = rowmean(med11-med14)

foreach var of varlist med3 med7 medweb  {
gen `var'_r = (`var' - 1)/4
}


*Soziodemographische Charakteristika
	*Alter
	gen young = V202
	replace young = 1 if V202 <= 35
	replace young = 0 if V202 > 35

	*Bildung
	recode V205 (16 15 = 1) (11 12 13 14 99 = 0), gen(eduhigh)

	*Geschlecht
	recode V201 (2 = 1) (1 = 0), gen(female)




***Interaktionseffekte Medien * Wahrnehmungen, Pr�dispositionen
	foreach var of varlist idgov pre5_r inter_r pre3_r succ_r  {
	   gen `var'_med3 = `var'*med3_r 
	}


	foreach var of varlist idgov pre5_r inter_r pre3_r succ_r  {
	   gen `var'_med7 = `var'*med7_r 
	}


	foreach var of varlist inter_r pre3_r pre5_r succ_r idgov {
	   gen `var'_medweb = `var'*medweb_r 
	}

	gen id_resp = 1
	replace id_resp = 0 if isaf_r == . | idgov == . | pre5_r == . | inter_r == . | pre3_r == . | succ_r == . | med3_r == . | med7_r == . | medweb_r == . | idgov_med3 == . | pre5_r_med3 == . | succ_r_med3 == . | idgov_med7 == . | pre5_r_med7 == . | succ_r_med7 == . | idgov_medweb == . | pre5_r_medweb == . | succ_r_medweb == . | young == . | eduhigh == . | female == .


*Analysen
*AV: Erfolgswahnehmungen
	**Baseline
	reg succ_r young eduhigh female if id_resp == 1
	estat vif, uncentered
	**allgemeine Dispositionen (Tabelle 1, 1. Spalte)
	reg succ_r idgov pre5_r inter_r pre3_r ///
	young eduhigh female if id_resp == 1
	estat vif, uncentered


*AV: ISAF
	**Baseline 
	reg isaf_r young eduhigh female if id_resp == 1
	estat vif, uncentered

	**Erfolgswahrnehmungen  (Tabelle 1, 2. Spalte)
	reg isaf_r succ_r ///
	young eduhigh female if id_resp == 1
	estat vif, uncentered

	**allgemeine Dispositionen  (Tabelle 1, 3. Spalte)
	reg isaf_r idgov pre5_r inter_r pre3_r ///
	young eduhigh female if id_resp == 1
	estat vif, uncentered

	**Erfolgswahrnehmungen und allgemeine Dispositionen  (Tabelle 1, 4. Spalte)
	reg isaf_r idgov pre5_r inter_r pre3_rz succ_r ///
	young eduhigh female if id_resp == 1
	estat vif, uncentered

*Meidationsanalyse (Tabelle 2)
	**Goodman-Sobel Test
	sgmediation isaf_r if id_resp == 1, mv(succ_r) iv(idgov)
	sgmediation isaf_r if id_resp == 1, mv(succ_r) iv(pre5_r)
	sgmediation isaf_r if id_resp == 1, mv(succ_r) iv(inter_r)
	sgmediation isaf_r if id_resp == 1, mv(succ_r) iv(pre3_r)


******************************Interaktionen zwischen der Mediennutzung (2 Einzelitems, Internetindex) und Pr�dispositionen (, Erfolg)
*AV: ISAF (Tabelle 3)
reg isaf_r ///
idgov pre5_r inter_r pre3_r succ_r ///
med3_r med7_r medweb_r ///
idgov_med3 pre5_r_med3 succ_r_med3 ///
idgov_med7 pre5_r_med7 succ_r_med7 ///
idgov_medweb pre5_r_medweb succ_r_medweb ///
young eduhigh female
estat vif, uncentered

grinter succ_r, inter(succ_r_med3) const02(med3_r) yscale(range(0 1)) ylabel(0(.1)1) xscale(range(0 1)) xlabel(0 (.1) 1)
lincom succ_r + 1*succ_r_med3

grinter idgov, inter(idgov_med7) const02(med7_r) yscale(range(-0.5 0.5)) ylabel(-0.5(.1)0.5) xscale(range(0 1)) xlabel(0 (.1) 1)
lincom idgov + 1*idgov_med7

grinter pre5_r, inter(pre5_r_med7) const02(med7_r) yscale(range(0 1)) ylabel(0(.1)1) xscale(range(0 1)) xlabel(0 (.1) 1)
lincom pre5_r + 1*pre5_r_med7

grinter succ_r, inter(succ_r_med7) const02(med7_r) yscale(range(0 1)) ylabel(0(.1)1) xscale(range(0 1)) xlabel(0 (.1) 1)
lincom succ_r + 1*succ_r_med7

